/*    */ package cc.s2m.web.s2mBlog.controller.admin;
/*    */ 
/*    */ import cc.s2m.util.BeanConverter;
/*    */ import cc.s2m.util.Page;
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.WeixinAdmin;
/*    */ import cc.s2m.web.s2mBlog.service.IWeixinAdmin;
/*    */ import cc.s2m.web.s2mBlog.util.MemcacheKeys;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import net.spy.memcached.MemcachedClient;
/*    */ import org.apache.commons.lang3.RandomStringUtils;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller("admin_WeixinAdminController")
/*    */ @RequestMapping({"/admin/weixinAdmin"})
/*    */ public class WeixinAdminController extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IWeixinAdmin weixinAdminService;
/*    */ 
/*    */   @Autowired
/*    */   private MemcachedClient memcachedClient;
/*    */ 
/*    */   @RequestMapping({"/list"})
/*    */   public String list(Model model, WeixinAdmin bean, Integer page)
/*    */   {
/* 32 */     if (page == null) page = Integer.valueOf(1);
/* 33 */     Map map = new HashMap();
/* 34 */     if (bean != null) {
/* 35 */       map.putAll(BeanConverter.toMap(bean, false));
/* 36 */       model.addAttribute("bean", bean);
/*    */     }
/* 38 */     Page pageBean = this.weixinAdminService.getPage(page.intValue(), 50, null, map);
/* 39 */     model.addAttribute("pageBean", pageBean);
/* 40 */     return "admin/weixinAdmin";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/add"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String add(Model model, Integer id) {
/* 45 */     if (id != null) {
/* 46 */       WeixinAdmin bean = (WeixinAdmin)this.weixinAdminService.selectByPrimaryKey(id);
/* 47 */       model.addAttribute("bean", bean);
/*    */     }
/* 49 */     String weixinAdminCode = RandomStringUtils.randomNumeric(6);
/* 50 */     this.memcachedClient.set(MemcacheKeys.WEIXIN_ADMIN_TOKEN.getKey(), 10, weixinAdminCode);
/* 51 */     model.addAttribute("weixinAdminCode", weixinAdminCode);
/* 52 */     return "admin/weixinAdmin_add";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/view"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String view(Model model, Integer id) {
/* 57 */     if (id != null) {
/* 58 */       WeixinAdmin bean = (WeixinAdmin)this.weixinAdminService.selectByPrimaryKey(id);
/* 59 */       model.addAttribute("bean", bean);
/*    */     }
/* 61 */     return "admin/weixinAdmin_view";
/*    */   }
/*    */   @RequestMapping(value={"/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String save(Model model, WeixinAdmin bean) {
/* 67 */     if (bean == null) {
/* 68 */       return "empty";
/*    */     }
/* 70 */     if (bean.getId() == null)
/*    */     {
/* 72 */       this.weixinAdminService.insertSelective(bean);
/*    */     }
/*    */     else {
/* 75 */       this.weixinAdminService.updateByPrimaryKeySelective(bean);
/*    */     }
/* 77 */     return "success";
/*    */   }
/*    */   @RequestMapping(value={"/del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String del(Integer id) {
/* 83 */     WeixinAdmin bean = (WeixinAdmin)this.weixinAdminService.selectByPrimaryKey(id);
/* 84 */     if (bean != null) {
/* 85 */       this.weixinAdminService.deleteByPrimaryKey(id);
/*    */     }
/* 87 */     return "success";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.admin.WeixinAdminController
 * JD-Core Version:    0.6.1
 */